package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter
@Getter
// 攻略点评
public class StrategyComment {

    public static final int STATE_NORMAL = 0; // 待审核
    public static final int STATE_COMMEND = 1; // 审核通过

    private Long id; //id

    private User user; // 用户

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
    private Date createTime; // 创建时间

    private String content; // 点评内容

    private String imgUrls; // 上传图片

    private Integer starNum; // 星级

    private Strategy strategy; // 攻略

    private Integer state; // 点评状态 0 待审核 1审核通过

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GTM+8")
    private Date commendTime; // 头条推荐时间

    // 模态框回显
    public String getJSONStr(){
        Map<String,Object> map = new HashMap<>();
        if (this.commendTime!=null){
            String commendTime = DateUtil.date2string(this.commendTime, "yyyy-MM-dd");
            map.put("commendTime", commendTime);
        }
        map.put("state",state);
        return JSONUtil.toJSONString(map);
    }

}